package com.zdgk.core.web.controller.mqtt;

import com.zdgk.core.mqtt.MqttClientConfig;
import com.zdgk.core.web.common.CommonResult;
import com.zdgk.core.web.controller.mqtt.entity.MqttStatusEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class MqttController {

    @Resource
    private MqttClientConfig mqttClientConfig;

    /**
     * modbus主站状态
     * @return
     */
    @GetMapping("/mqtt/status")
    public CommonResult<?> mqttStatus(){
        MqttStatusEntity modbusStatus = new MqttStatusEntity();
        modbusStatus.setIsConnected(mqttClientConfig.isConnected());
        return CommonResult.data(modbusStatus);
    }

}
